import java.io.*;
import java.time.LocalDate;

/**
 * @author: xinmi
 * @date: 2020/11/10
 * @description:
 */
public class FileWrite2 {

    public static void main(String[] args) throws IOException {

        System.out.println("user_dir:" + System.getProperty("user.dir"));

        File dataDir = new File(System.getProperty("user.dir") + "/data/card");
        if (!dataDir.exists() && !dataDir.isDirectory())
            if (!dataDir.mkdir()) {
                System.out.println("mkdir data failed");
            }

        LocalDate localDate = LocalDate.now();
        String fileName = System.getProperty("user.dir") + "/data/card/card"+localDate.toString().replace("-","_")+".txt";
        System.out.println(fileName);

        BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));

        String words = "2019年1月18日新追加内容!";
        bw.write(words);

        //刷新流
        bw.flush();

        //关闭资源
        bw.close();
    }
}
